package com.yqg.protection.listenern;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.yqg.protection.controller.dto.ImportEquipmentDeviceDto;
import com.yqg.protection.entity.EquipmentDevice;
import com.yqg.protection.mapper.EquipmentDeviceMapper;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * projectName:xf-service1
 * author:zxf
 * time:2024/10/17 16:28
 * description:
 */
@Component
public class EquipmentDeviceListener extends AnalysisEventListener<ImportEquipmentDeviceDto> {

    @Resource
    private EquipmentDeviceMapper equipmentDeviceMapper;

    @Override
    public void invoke(ImportEquipmentDeviceDto importEquipmentDeviceDto, AnalysisContext analysisContext) {
        EquipmentDevice equipmentDevice = new EquipmentDevice();
        BeanUtil.copyProperties(importEquipmentDeviceDto, equipmentDevice, true);
        equipmentDevice.setIsDelete(0);
        equipmentDeviceMapper.insert(equipmentDevice);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
